﻿using DevTeam;

using System;
namespace ConfExpert.Forms.Rapor.YeniYapi
{
    public partial class GenelStok : XRapor
    {
        string tip, CP;
        public GenelStok(string _tip, string _CP)
        {
            InitializeComponent();
            tip = _tip;
            CP = _CP;
        }

        private void Form_Load(object sender, EventArgs e)
        {



            switch (tip)
            {
                case "ESP":

                    switch (CP)
                    {
                        case "C":
                            gv.Init("getESPStokByCustomer");
                            gv.AddDetailGrid(gv2, "CustomerId");
                            gv2.MakeColumnInvisible("CustomerId");
                            break;

                        case "P":
                            gv.Init("getESPStokByArticle");
                            gv.AddDetailGrid(gv2, "ProductId");
                            break;
                    }

                    this.Text = "ESPStoku";
                    gv.FormatAsNumber(1, "ToplamIdle", "ToplamAyrilan", "ToplamRezerve", "GenelToplam");
                    gv.AddSummary("ToplamIdle", "ToplamAyrilan", "ToplamRezerve", "GenelToplam", "TopAdedi");
                    gv2.FormatAsNumber(1, "Idle", "Ayrilan", "Rezerve", "Toplam");
                    gv2.AddSummary("Idle", "Ayrilan", "Rezerve", "Toplam", "TopAdedi");
                    break;

                default:
                    this.Text = "GenelStok";
                    gv.Init("getGenelStok");
                    gv.AddDetailGrid(gv2, "CustomerId");
                    gv.FormatAsNumber(1, "ToplamIdle", "ToplamAyrilan", "ToplamRezerve", "OnHold_R", "OnHold_C", "GenelToplam");
                    gv.AddSummary("ToplamIdle", "ToplamAyrilan", "ToplamRezerve", "OnHold_R", "OnHold_C", "GenelToplam", "TopAdedi");
                    gv2.FormatAsNumber(1, "Idle", "Ayrilan", "Rezerve", "OnHold_R", "OnHold_C", "Toplam");
                    gv2.AddSummary("Idle", "Ayrilan", "Rezerve", "OnHold_R", "OnHold_C", "Toplam", "TopAdedi");
                    break;
            }

            gv.MakeReadOnly();
            gv.FormatAsNumber(0, "TopAdedi");

            gv2.MakeReadOnly();
            gv2.FormatAsNumber(0, "TopAdedi");

            btnRapor.ItemClick += btnRapor_ItemClick;

            //GridManager gm = GridManager.GetManager(gv);
            //gm.GridMenu.AddMenu("Detay Göster", GenelStokDetay);

            gv.BestFitColumns();
            gv2.BestFitColumns();
            splitter.AutoSize();
        }

        void btnRapor_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            xrGenelStok gs = new xrGenelStok();
            ReportViewer.View(gs);
        }

        //void GenelStokDetay(object sender, EventArgs e)
        //{
        //    GridHitInfo hi = gv.CalcHitInfo(gc.PointToClient(MousePosition));
        //    if ((hi.InRow ) && gv.FocusedRowHandle > -1)
        //    {
        //        string Customer = gv.GetFocusedRowCellDisplayText("Musteri");
        //        using (Forms.Depo.GenelStokDetay ad = new Depo.GenelStokDetay(Customer))
        //        {
        //            ad.ShowDialog();
        //        }
        //    }
        //}

    }
}